package cn.iocoder.yudao.module.bpm.dal.mysql.source;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.source.vo.SourceCatalogWithSourceDataRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.source.vo.SourcePageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.source.SourceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 资源信息 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface SourceMapper extends BaseMapperX<SourceDO> {

    default PageResult<SourceDO> selectPage(SourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SourceDO>()
                .likeIfPresent(SourceDO::getSourceName, reqVO.getSourceName())
                .eqIfPresent(SourceDO::getSourceCode, reqVO.getSourceCode())
                .eqIfPresent(SourceDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(SourceDO::getSourceDesc, reqVO.getSourceDesc())
                .eqIfPresent(SourceDO::getFileType, reqVO.getFileType())
                .eqIfPresent(SourceDO::getFileSize, reqVO.getFileSize())
                .eqIfPresent(SourceDO::getFile, reqVO.getFile())
                .eqIfPresent(SourceDO::getSourceFrom, reqVO.getSourceFrom())
                .eqIfPresent(SourceDO::getSourceStatus, reqVO.getSourceStatus())
                .betweenIfPresent(SourceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SourceDO::getId));
    }

    default List<SourceDO> queryByIds(List<Long> list){
        return selectList(new LambdaQueryWrapperX<SourceDO>()
                .in(SourceDO::getId, list));
    };

    List<SourceCatalogWithSourceDataRespVO> queryListByIds(List<Long> list);
}